package com.ailink.concurrent.lock;

import java.util.concurrent.CountDownLatch;

/**
 * Created by Administrator on 2018/10/23
 */
public class TestCountDownLatch {
    public static void main(String[] args) {
        CountDownLatch countDownLatch = new CountDownLatch(1);

        new Thread(() -> {
            try {
                System.out.println("wait");
                Thread.sleep(10000);
                System.out.println("countdown");
                countDownLatch.countDown();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        try {
            countDownLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }
}
